<h3 style='text-align:center'>新增商品或服务</h3>

<div style='margin:10px auto;display:flex'>
	<div style='width:100px;text-align:right'>分类：</div>
	<div style='flex:1;'>
		<select id="GoodsConAdd_TypeSel1"></select>
		<select id="GoodsConAdd_TypeSel2"></select>
		<select id="GoodsConAdd_TypeSel3"></select>
	</div>
</div>

<div style='margin:10px auto;display:flex'>
	<div style='width:100px;text-align:right'>名称：</div>
	<div style='flex:1'><input id='StoreGoodsAdd_GoodsTitle' style='width:90%' /></div>
</div>
<div style='margin:10px auto;display:flex'>
	<div style='width:100px;;text-align:right'>编号：</div>
	<div style='flex:1'><input id='StoreGoodsAdd_GoodsNumber' />(可选)</div>
</div>
<div style='margin:10px auto;display:flex'>
	<div style='width:100px;text-align:right'>价格：</div>
	<div style='flex:1'><input id='StoreGoodsAdd_GoodsPrice' /></div>
</div>

<div style='margin:10px auto;display:flex'>
	<div style='width:100px;;text-align:right'>详情：</div>
	<div style='flex:1'><textarea id="StoreGoodsAdd_GoodsInfo" style='width:90%;height:150px;resize:none' ></textarea></div>
</div>



<div style='text-align:center;margin:20px auto'>
	<button id='StoreGoodsAdd_SubBtn'>提交</button>
	<button id='StoreGoodsAdd_BackBtn'>返回</button>
</div>



<script>

	//获取商品分类列表
	_getGoodsTypeListFull(function(GoodsTypes){
		//分类数据填充到元素
		GoodsTypeInit(GoodsTypes,'#GoodsConAdd_TypeSel1','#GoodsConAdd_TypeSel2','#GoodsConAdd_TypeSel3');
	});


	//提交按钮
	$('#StoreGoodsAdd_SubBtn').click(function(){
		var t1 = $('#GoodsConAdd_TypeSel1').find('option:selected').val();
		var t2 = $('#GoodsConAdd_TypeSel2').find('option:selected').val();
		var t3 = $('#GoodsConAdd_TypeSel3').find('option:selected').val();
		var t1_text = $('#GoodsConAdd_TypeSel1').find('option:selected').text();
		var t2_text = $('#GoodsConAdd_TypeSel2').find('option:selected').text();
		var t3_text = $('#GoodsConAdd_TypeSel3').find('option:selected').text();

		var typeSet = t1_text+"-"+t2_text+"-"+t3_text;
		
		var GoodsTitle = ChangeChar($('#StoreGoodsAdd_GoodsTitle').val().trim());
		Field_Check(/^.{1,50}$/,GoodsTitle,'js商品名1-50个字符!');

		var GoodsNumber = $('#StoreGoodsAdd_GoodsNumber').val().trim();
		Field_Check(/^[0-9]{1,4}$|^$/,GoodsNumber,'js编号为0-4四位数字!');

		var GoodsPrice = $('#StoreGoodsAdd_GoodsPrice').val().trim();
		Field_Check(/^[1-9][0-9]{0,8}(\.[0-9]{1,2})?$/,GoodsPrice,'js价格输入有误!');

		var GoodsInfo = ChangeChar($('#StoreGoodsAdd_GoodsInfo').val().trim());
		Field_Check(/^.{1,}$/,GoodsInfo,'js商品详情不得为空!');


		var data = {
			type:'storeGoodsAdd',
			title:GoodsTitle,
			number:GoodsNumber,
			price:GoodsPrice,
			info:GoodsInfo,
			t1:t1,
			t2:t2,
			t3:t3,
			typeSet:typeSet,
			store_id:accountInfo.id,
		}

		AjaxStore(data,function(res){
			var tmp = _checkJsonFormat(res);
			switch(tmp.stat){
				case 'ok':A('添加成功!');BackCon();GoodsCon_Init(1);break;
				case 'err2':A('商品个数超限！');break;
				case 'err3':A('操作异常！');break;
				case 'errStat':A('商户状态异常！');break;
			}
		});
	});












	//返回按钮 
	$('#StoreGoodsAdd_BackBtn').click(function(){
		BackCon();
	});



	function BackCon(){
		$('input').val('');
		$('textarea').val('');
		$('#GoodsCon_List').show();
		$('#GoodsCon_AddBtn').show();
		$('#GoodsCon_Add').hide();
	}

</script>